|
In computer graphics, alpha compositing is the process of combining an image with a background to create the appearance of partial or full transparency. It is often useful to render image elements in separate passes, and then combine the resulting multiple 2D images into a single, final image called the composite. For example, compositing is used extensively when combining computer-rendered image elements with live footage. In order to combine these image elements correctly, it is necessary to keep an associated ''matte'' for each element. This matte contains the coverage information—the shape of the geometry being drawn—making it possible to distinguish between parts of the image where the geometry was actually drawn and other parts of the image that are empty. ==Description== To store matte information, the concept of an alpha channel was introduced by Alvy Ray Smith in the late 1970s, and fully developed in a 1984 paper by Thomas Porter and Tom Duff. In a 2D image element, which stores a color for each pixel, additional data is stored in the alpha channel with a value between 0 and 1. A value of 0 means that the pixel does not have any coverage information and is transparent; i.e. there was no color contribution from any geometry because the geometry did not overlap this pixel. A value of 1 means that the pixel is opaque because the geometry completely overlapped the pixel. If an alpha channel is used in an image, it is common to also multiply the color by the alpha value, to save on additional multiplications during compositing. This is usually referred to as ''premultiplied alpha''. Assuming that the pixel color is expressed using ''straight'' (non-premultiplied) RGBA tuples, a pixel value of (0.0, 0.5, 0.0, 0.5) implies a pixel that has 50% of the maximum green intensity and 50% opacity. If the color were fully green, its RGBA would be (0, 1, 0, 0.5). However, if this pixel uses premultiplied alpha, all of the RGB values (0, 1, 0) are multiplied by 0.5 and then the alpha is appended to the end to yield (0, 0.5, 0, 0.5). In this case, the 0.5 value for the G channel actually indicates 100% green intensity (with 50% opacity). For this reason, knowing whether a file uses premultiplied or straight alpha is essential to correctly process or composite it. Premultiplied alpha has some practical advantages over normal alpha blending because premultiplied alpha blending is associative, and interpolation and filtering give correct results. Ordinary interpolation without premultiplied alpha leads to RGB information leaking out of fully transparent (A=0) regions, even though this RGB information is ideally invisible. When interpolating images with abrupt borders between transparent and opaque regions, this can result in borders of colors that were not visible in the original image. In addition, premultiplied alpha allows regions of regular alpha blending and regions with additive blending mode to be encoded within the same image.〔http://home.comcast.net/~tom_forsyth/blog.wiki.html#Premultiplied alpha〕 Premultiplication causes a loss of precision in the RGB values, so that a noticeable loss of quality can result if the color information is later brightened or if the alpha channel is removed. This loss of precision also makes premultiplied images easier to compress, as they do not record the color variations hidden inside transparent regions. With the existence of an alpha channel, it is possible to express compositing image operations using a ''compositing algebra''. For example, given two image elements A and B, the most common compositing operation is to combine the images such that A appears in the foreground and B appears in the background. This can be expressed as A over B. In addition to over, Porter and Duff defined the compositing operators in, held out by (usually abbreviated out), atop, and xor (and the reverse operators rover, rin, rout, and ratop) from a consideration of choices in blending the colors of two pixels when their coverage is, conceptually, overlaid orthogonally: The over operator is, in effect, the normal painting operation (see Painter's algorithm). The in operator is the alpha compositing equivalent of clipping. As an example, the over operator can be accomplished by applying the following formula to each pixel value: : where is the result of the operation, is the color of the pixel in element A, is the color of the pixel in element B, and and are the alpha of the pixels in elements A and B respectively. If it is assumed that all color values are premultiplied by their alpha values (), we can rewrite the equation for output color as: : and resulting alpha channel value is : : 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「alpha compositing」の詳細全文を読む スポンサード リンク
|